<template>
  <div>
    <span ref="countup"></span>
    <sapn>{{ title }}</sapn>
  </div>
</template>

<script>
import { CountUp } from 'countup.js'
export default {
  name: 'countup-demo',
  props: {
    end: {
      type: Number,
      default: 0
    },
    options: {
      type: Object
    },
    autoplay: {
      type: Boolean,
      default: true

    }
  },
  data () {
    return {
      numAnim: null,
      title: 'countup组件',
      
    }
  },
  mounted(){
    if (this.autoplay) {
      this.initCountUp()
    }
    
  },
  methods:{
    initCountUp(){
      this.numAnim = new CountUp(this.$refs.countup, this.end, this.options)
      this.numAnim.start();
    }
  }
}
</script>

<style>

</style>
